package icon;

public class Timer {
    public static  void timer(int n){
        System.out.println("-----当0 < amount < "+n+" ，执行1000次------");
        long startTime;
        long endTime;

        int[] conis = {1, 2, 5, 10, 50, 100};

        int[] arr1 = Random.genrandom(n);
        //Solution1

        startTime = System.currentTimeMillis();
        for (int i = 0; i < 1000; i++) {
            Solution.coinChange(conis,arr1[i]);
        }
        endTime = System.currentTimeMillis();
        System.out.println( "暴力解法："+(endTime-startTime) + "ms" );


        //Solution2
        startTime = System.currentTimeMillis();
        for (int i = 0; i < 1000; i++) {
            Solution2.coinChange(conis,arr1[i]);
        }
        endTime = System.currentTimeMillis();
        System.out.println( "记忆优化："+(endTime-startTime) + "ms" );

        //Solution3
        startTime = System.currentTimeMillis();
        for (int i = 0; i < 1000; i++) {
            Solution2.coinChange(conis,arr1[i]);
        }
        endTime = System.currentTimeMillis();
        System.out.println( "迭代解法1："+(endTime-startTime) + "ms" );

        //Solution4
        startTime = System.currentTimeMillis();
        for (int i = 0; i < 1000; i++) {
            Solution2.coinChange(conis,arr1[i]);
        }
        endTime = System.currentTimeMillis();
        System.out.println( "迭代解法2："+(endTime-startTime) + "ms" );
    }
}
